2.4編輯faq-book.com.zone 正解(請依照個人設定)
[root@localhost ~]# cd /var/named/chroot/var/named/
[root@localhost named]# vim faq-book.com.zone
$TTL 3600
@ IN SOA ns.faq-book.com. root.faq-book.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS ns.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN NS ns1.faq-book.com.
IN MX 5 mail
IN A 192.168.1.122
ns IN A 192.168.1.122
ns1 IN A 192.168.1.123
www IN A 192.168.1.122
mail IN A 192.168.1.122
blog IN A 192.168.1.122
ftp IN CNAME www
2.5 編輯192.168.1.local 正解
[root@localhost ~]# cd /var/named/chroot/var/named/
[root@localhost named]# vim 192.168.1.local
$TTL 3600
@ IN SOA ns.faq-book.com. root.faq-book.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.faq-book.com.
IN NS ns1.faq-book.com.
122 IN PTR faq-book.com.
122 IN PTR blog.faq-book.com.
122 IN PTR www.faq-book.com.
122 IN PTR mail.faq-book.com.
建立Slave DNS Server
3.1 設定named.conf文件
先建立一個named.conf文件,然後在修改內容。
[root@localhost ~]# cd /var/named/chroot/etc/
[root@localhost etc]# cp named.rfc1912.zones named.conf
[root@localhost etc]# chown root:named named.conf
3.2 編輯DNS主要設定檔named.conf,黃色文字部份請依個人需求自行設定
[root@localhost ~]# vim /var/named/chroot/etc/named.conf
// named.rfc1912.zones:
// Provided by Red Hat caching-nameserver package
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// See /usr/share/doc/bind*/sample/ for example named configuration files.
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };
version "None of your business";
forwarders { 168.95.1.1; 168.95.192.2; 8.8.8.8; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
#正解
zone "faq-book.com" IN {
type slave;
file "slaves/faq-book.com.zone";
masters { 192.168.1.122; };
};
#反解
zone "192.168.1.in-addr.arpa" IN {
type slave;
file "slaves/192.168.1.local";
masters { 192.168.1.122; };
};
3.3 設定完這兩台DNS Server後就請啟動或是重新啟動dns服務。
[root@localhost ~]# /etc/init.d/named restart
測試DNS
[root@localhost ~]# nslookup
server 127.0.0.1 #用本機的DNS做測試
Default server: 127.0.0.1
Address : 127.0.0.1#53
faq-book.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: faq-book.com
Address: 192.168.1.122
set q=mx
faq-book.com
Server: 127.0.0.1
Address: 127.0.0.1#53
faq-book.com mail exchanger = 5 mail.faq-book.com.
set q=ns
faq-book.com
Server: 127.0.0.1
Address: 127.0.0.1#53
faq-book.com nameserver = ns.faq-book.com.
faq-book.com nameserver = ns1.faq-book.com.
set q=a
bolg.faq-book.com
Server: 127.0.0.1
Address: 127.0.0.1#53
blog.faq-book.com canonical name = www.faq-book.com.
Name: www.faq-book.com
Address: 192.168.1.122
如果測試完DNS後都正常的話就表示大制上設定好了。
5.設定開機自動執行
[root@localhost ~]# chkconfig named on
Linux DNS(BIND)安裝與設定(上)
全文同步於FAQ-BOOK
IT鐵人文章分享